﻿#region Imports

using System;
using System.Reflection;
using Common.Logging;
using Spring.Aop;

#endregion

namespace d3PrtDgn.Core.Aspects
{
	/// <summary>
	/// Advice for logging errors
	/// </summary>
	class ErrorLoggingAdvice : IThrowsAdvice
	{
		#region Private fields

		private static readonly ILog log = LogManager.GetLogger("ErrorLogger");

		#endregion

		#region Public methods

		/// <summary>
		/// Log errors after throwing
		/// </summary>
		/// <param name="method"></param>
		/// <param name="args"></param>
		/// <param name="target"></param>
		/// <param name="ex"></param>
		public void AfterThrowing(MethodInfo method, object[] args, object target, Exception ex)
		{
			log.Error("Invocation of method " + method.Name + " failed.", ex);
		}

		#endregion
	}
}
